<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Ajax extends Controller{

	public function action_index() {

	}
	
	public function action_get_image(){
		$page = $this->request->post('page');
		if ($this->request->is_ajax() && isset($page)) {
			$this->auto_render = FALSE;
			$offset = ($page-1)*12;
			$str= array();
			$images = ORM::factory('image')->offset($offset)->limit(12)->find_all();

			foreach ($images as $val){
				$str[]	= array(
					'images' => '/media/uploads/'.$val->mini,
					'id' =>$val->id
				);
			}
		}
	
		$this->content = $str;
	}
	
	public function action_full(){
		$id = $this->request->post('id');
		$str= array();
		if ($this->request->is_ajax() && isset($id)) {
			$this->auto_render = FALSE;
			
			$full = ORM::factory('image',$id);
		
			$str = array(
					'full' => '/media/uploads/'.$full->full,
					'text' =>$full->text
			);
		}	
		$this->content = $str;
		
	}
	
	 public function after(){
	
		
		
		$this->response->body(json_encode($this->content));
		parent::after();
	}
}